package com.csc.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.csc.domain.Customer;

@Repository
public class CustomerDaoImpl implements CustomerDao {

	@PersistenceContext
	private EntityManager em;

	static final Logger logger = Logger.getLogger(AccountDaoImpl.class);

	public List<Customer> getAllCustomer() {

		logger.info("Go getAllCustomer");
		// query get list customer
		TypedQuery<Customer> query = em.createQuery(
				"SELECT cus FROM Customer cus ", Customer.class);
		
		return query.getResultList();
	}

	public Customer getCustomerById(int customerId) {

		logger.info("Go getCustomerById");

		return em.find(Customer.class, customerId);

	}

}
